$.module('DOCTOR.Select', function () {
    return {
        /**
         * 用户列表插件
         * 使用方法：
         *  $("#bind_user").on('click', function () {
                DOCTOR.Select.showUser(this);
            });
         */
        showAllUser: function (obj) {
            var that = this;
            var search = '';
            search += '<div class="form-group">';
            search += '<input id="tool_s_user_id" type="text" class="form-control" placeholder="用户ID">';
            search += '<input id="tool_s_nickname" type="text" class="form-control" placeholder="用户昵称">';
            search += '</div>';
            var $userModal = $(that.initModal('用户列表', search));
            $(document.body).append($userModal);
            $userModal.modal('show');
            that.showUserData(1, 10, obj.id, -1); // 调用显示用户列表页面
            that.showUserEvent(obj.id, -1);
        },
        showUser: function (obj) {
            var that = this;
            var search = '';
            search += '<div class="form-group">';
            search += '<input id="tool_s_user_id" type="text" class="form-control" placeholder="用户ID">';
            search += '<input id="tool_s_nickname" type="text" class="form-control" placeholder="用户昵称">';
            search += '</div>';
            var $userModal = $(that.initModal('用户列表', search));
            $(document.body).append($userModal);
            $userModal.modal('show');
            that.showUserData(1, 10, obj.id); // 调用显示用户列表页面
            that.showUserEvent(obj.id, 2);
        },
        showUserData: function (pageNumber, pageSize, fieldId) {
            var that = this;
            that.showLoading(true);
            var search_id = $("#tool_s_user_id").val();
            var search_name = $("#tool_s_nickname").val();
            if (typeof(search_name) == "undefined") {
                search_name = '';
            }
            SYS.Core.ajax({
                url: "base/user/list",
                common: {
                    page: pageNumber ? pageNumber : 1,
                    size: pageSize ? pageSize : 10
                },
                data: {
                    id: search_id || 0,
                    nickname: search_name
                },
                success: function (data) {
                    var obj = {
                        'pageNumber': data.data.extra.current_page,
                        'pageSize': data.data.extra.page_size,
                        'totalRows': data.data.extra.all_count,
                        'data': data.data.list
                    };
                    $("#tool_table").bootstrapTable('destroy');    //销毁table
                    $('#tool_table').bootstrapTable({
                        striped: true,
                        singleSelect: true,
                        pagination: true,
                        paginationDetail: false,
                        pageNumber: obj.pageNumber,
                        pageSize: obj.pageSize,
                        totalRows: obj.totalRows,
                        pageList: [10, 50, 100, 200],
                        sidePagination: 'server',
                        clickToSelect: true,
                        idField: 'id',
                        data: obj.data,
                        columns: [
                            {field: 'id', title: 'ID', align: 'center'},
                            {field: 'avatarUrl', title: '头像', align: 'center',
                                formatter: function (img) {
                                    return SYS.Tool.getUserImg(img);
                                }
                            },
                            {field: 'nickname', title: '昵称', align: 'center',
                                formatter: function (val) {
                                    return decodeURI(val);
                                }
                            },
                            {field: 'mobile', title: '手机号', align: 'center'},
                            {
                                field: 'do', title: '操作', align: 'center',
                                formatter: function (value, row, index) {
                                    var content = row.nickname ? row.nickname.replace(/[\r\n]/g, "") : '-';
                                    return '<a href="javascript:void(0)" onclick="DOCTOR.Select.toAdd(' + row.id + ',\'' + content + '\',\'' + fieldId + '\')" class="text-do-add"><i class="fa fa-plus glyphicon_size"></i></a>';
                                }
                            }
                        ],
                        onPageChange: function (number, size) {
                            that.showUserData(number, size, fieldId);
                        },
                        onRefreshTable: function () {   //表格右侧刷新按钮
                            that.showUserData(obj.pageNumber, obj.pageSize, fieldId);
                        }
                    });
                    that.showLoading(false);
                }
            });
        },
        showUserEvent: function (fieldId) {
            var that = this;
            // 对用户添加Enter键支持
            var $stb = $("#search-toolbar-common");
            $stb.on("click", "#tool_btn_search", function () {
                that.showUserData(1, 10, fieldId);
            }).on("keydown", "input", function (e) {
                if (e.keyCode == 13) {
                    that.showUserData(1, 10, fieldId);
                }
            }).on('click', "#tool_btn_remove", function () {
                $("#" + fieldId).val('');
                $("#" + fieldId).removeAttr('data-id');
                $("#tool_modal").modal('hide');
            });
            that.initEvent();
        },

        /**
         * 产品插件
         * @param obj
         */
        showProduct: function (obj) {
            var that = this;
            var search = '';
            search += '<div class="form-group">';
            search += '<input id="tool_s_product_id" type="number" class="form-control" placeholder="产品ID">';
            search += '<input id="tool_s_product_name" type="text" class="form-control" placeholder="产品名称">';
            search += '<input id="tool_s_product_en_name" type="text" class="form-control" placeholder="产品英文名称">';
            search += '</div>';
            var $userModal = $(that.initModal('产品列表', search));
            $(document.body).append($userModal);
            $userModal.modal('show');
            that.showProductData(1, 10, obj.id);
            that.showProductEvent(obj.id);
        },
        showProductData: function (pageNumber, pageSize, fieldId) {
            var that = this;
            that.showLoading(true);
            var search_id = $("#tool_s_product_id").val();
            var search_name = $("#tool_s_product_name").val();
            var search_en_name = $("#tool_s_product_en_name").val();
            if (typeof(search_name) == "undefined") {
                search_name = '';
            }
            if (typeof(search_en_name) == "undefined") {
                search_name = '';
            }
            SYS.Core.ajax({
                url: "base/product/list",
                common: {
                    page: pageNumber ? pageNumber : 1,
                    size: pageSize ? pageSize : 5,
                    order: "create_time:-1"
                },
                data: {
                    productid: search_id || 0,
                    productname: search_name,
                    productenname: search_en_name
                },
                success: function (data) {
                    var obj = {
                        'pageNumber': data.data.extra.current_page,
                        'pageSize': data.data.extra.page_size,
                        'totalRows': data.data.extra.all_count,
                        'data': data.data.list
                    };
                    $("#tool_table").bootstrapTable('destroy');    //销毁table
                    $('#tool_table').bootstrapTable({
                        striped: true,
                        singleSelect: true,
                        pagination: true,
                        paginationDetail: false,
                        pageNumber: obj.pageNumber,
                        pageSize: obj.pageSize,
                        totalRows: obj.totalRows,
                        pageList: [10, 50, 100, 200],
                        sidePagination: 'server',
                        clickToSelect: true,
                        idField: '_id',
                        data: obj.data,
                        columns: [
                            {field: 'checked', checkbox: true} ,
                            {field: 'productid', title: '编号', align: 'center'},
                            {field: 'productname', title: '产品名称', align: 'center'},
                            {field: 'productenname', title: '产品英文名称', align: 'center'},
                            {field: 'pic', title: '封面', align: 'center',
                                formatter:function (val,row,index){
                                    if(val && val != '') {
                                        if (val.indexOf("http") == -1) {
                                            return "<img src='https://xcx.championwei.cn/upload/admin/images/product/" + val + "' style='width:100px; height:50px;' />";
                                        } else {
                                            return "<img src='" + val + "' style='width:100px; height:50px;' />";
                                        }
                                    }
                                    return '-';
                                }
                            },
                            {
                                field: 'do', title: '操作', align: 'center',
                                formatter: function (value, row, index) {
                                    var content = row.productname ? encodeURI(row.productname.replace(/[\r\n]/g, "")) : '-';
                                    return '<a href="javascript:void(0)" onclick="DOCTOR.Select.toAdd(' + row.productid + ',\'' + content + '\',\'' + fieldId + '\')" class="text-do-add"><i class="fa fa-plus glyphicon_size"></i></a>';
                                }
                            }
                        ],
                        onPageChange: function (number, size) {
                            that.showProductData(number, size, fieldId, free_trial);
                        },
                        onRefreshTable: function () {   //表格右侧刷新按钮
                            that.showProductData(obj.pageNumber, obj.pageSize, fieldId);
                        }
                    });
                    that.showLoading(false);
                }
            });
        },
        showProductEvent: function (fieldId) {
            var that = this;
            // 对用户添加Enter键支持
            var $stb = $("#search-toolbar-common");
            $stb.on("click", "#tool_btn_search", function () {
                that.showProductData(1, 5, fieldId);
            }).on("keydown", "input", function (e) {
                if (e.keyCode == 13) {
                    that.showProductData(1, 5, fieldId);
                }
            }).on('click', "#tool_btn_remove", function () {
                $("#" + fieldId).val('');
                $("#" + fieldId).removeAttr('data-id');
                $("#tool_modal").modal('hide');
            });
            that.initEvent();
        },

        /**
         * 组织架构版本
         *
         * @param obj
         */
        showOrgVersion: function (obj) {
            var that = this;
            var search = '';
            search += '<div class="form-group">';
            search += '<input id="tool_s_id" type="number" class="form-control" placeholder="组织架构版本ID">';
            search += '<input id="tool_s_name" type="text" class="form-control" placeholder="组织架构版本号">';
            search += '</div>';
            var $userModal = $(that.initModal('组织架构版本列表', search));
            $(document.body).append($userModal);
            $userModal.modal('show');
            that.showOrgVersionData(1, 10, obj.id);
            that.showOrgVersionEvent(obj.id);
        },
        showOrgVersionData: function (pageNumber, pageSize, fieldId) {
            var that = this;
            that.showLoading(true);

            let search_id = $("#tool_s_id").val();
            let search_name = $("#tool_s_name").val();

            if (typeof(search_name) == "undefined") {
                search_name = '';
            }
            SYS.Core.ajax({
                url: "base/orgVersion/list",
                common: {
                    page: pageNumber ? pageNumber : 1,
                    size: pageSize ? pageSize : 5,
                    order: "create_time:-1"
                },
                data: {
                    Id: search_id || 0,
                    Version: search_name,
                    Active: 1
                },
                success: function (data) {
                    var obj = {
                        'pageNumber': data.data.extra.current_page,
                        'pageSize': data.data.extra.page_size,
                        'totalRows': data.data.extra.all_count,
                        'data': data.data.list
                    };
                    $("#tool_table").bootstrapTable('destroy');    //销毁table
                    $('#tool_table').bootstrapTable({
                        striped: true,
                        singleSelect: true,
                        pagination: true,
                        paginationDetail: false,
                        pageNumber: obj.pageNumber,
                        pageSize: obj.pageSize,
                        totalRows: obj.totalRows,
                        pageList: [10, 50, 100, 200],
                        sidePagination: 'server',
                        clickToSelect: true,
                        idField: '_id',
                        data: obj.data,
                        columns: [
                            {field: 'Id', title: '组织机构版本ID', align: 'center'},
                            {field: 'Version', title: '组织机构版本号', align: 'center'},
                            {field: 'Active', title: '是否启用', align: 'center',
                                formatter: function (value,row) {
                                    return value == 1 ? '<label class="text-success">启用</label>' : '<label class="text-danger">不启用</label>';
                                }
                            },
                            {
                                field: 'do', title: '操作', align: 'center',
                                formatter: function (value, row, index) {
                                    let content = row.Version ? encodeURI(row.Version.replace(/[\r\n]/g, "")) : '-';
                                    return '<a href="javascript:void(0)" onclick="DOCTOR.Select.toAdd(' + row.Id + ',\'' + content + '\',\'' + fieldId + '\')" class="text-do-add"><i class="fa fa-plus glyphicon_size"></i></a>';
                                }
                            }
                        ],
                        onPageChange: function (number, size) {
                            that.showOrgVersionData(number, size, fieldId);
                        },
                        onRefreshTable: function () {   //表格右侧刷新按钮
                            that.showOrgVersionData(obj.pageNumber, obj.pageSize, fieldId);
                        }
                    });
                    that.showLoading(false);
                }
            });
        },
        showOrgVersionEvent: function (fieldId) {
            var that = this;
            // 对用户添加Enter键支持
            var $stb = $("#search-toolbar-common");
            $stb.on("click", "#tool_btn_search", function () {
                that.showOrgVersionData(1, 5, fieldId);
            }).on("keydown", "input", function (e) {
                if (e.keyCode == 13) {
                    that.showOrgVersionData(1, 5, fieldId);
                }
            }).on('click', "#tool_btn_remove", function () {
                $("#" + fieldId).val('');
                $("#" + fieldId).removeAttr('data-id');
                $("#tool_modal").modal('hide');
            });
            that.initEvent();
        },

        /**
         * 组织结构
         *
         * @param obj
         */
        showOrg: function (obj) {
            var that = this;
            var search = '';
            search += '<div class="form-group">';
            search += '<input id="tool_s_id" type="number" class="form-control" placeholder="组织架构ID">';
            search += '<input id="tool_s_name" type="text" class="form-control" placeholder="组织架构名称">';
            search += '</div>';
            var $userModal = $(that.initModal('管理口径组织架构列表', search));
            $(document.body).append($userModal);
            $userModal.modal('show');
            that.showOrgData(1, 10, obj.id);
            that.showOrgEvent(obj.id);
        },
        showOrgData: function (pageNumber, pageSize, fieldId) {
            var that = this;
            that.showLoading(true);

            let search_id = $("#tool_s_id").val();
            let search_name = $("#tool_s_name").val();

            if (typeof(search_name) == "undefined") {
                search_name = '';
            }
            SYS.Core.ajax({
                url: "base/org/list",
                common: {
                    page: pageNumber ? pageNumber : 1,
                    size: pageSize ? pageSize : 5,
                    order: "create_time:-1"
                },
                data: {
                    Id: search_id || 0,
                    Name: search_name,
                    Flag: -1
                },
                success: function (data) {
                    var obj = {
                        'pageNumber': data.data.extra.current_page,
                        'pageSize': data.data.extra.page_size,
                        'totalRows': data.data.extra.all_count,
                        'data': data.data.list
                    };
                    $("#tool_table").bootstrapTable('destroy');    //销毁table
                    $('#tool_table').bootstrapTable({
                        striped: true,
                        singleSelect: true,
                        pagination: true,
                        paginationDetail: false,
                        pageNumber: obj.pageNumber,
                        pageSize: obj.pageSize,
                        totalRows: obj.totalRows,
                        pageList: [10, 50, 100, 200],
                        sidePagination: 'server',
                        clickToSelect: true,
                        idField: '_id',
                        data: obj.data,
                        columns: [
                            {field: 'Id', title: '组织架构Id', align: 'center'},
                            {field: 'Name', title: '名称', align: 'center'},
                            {field: 'NodeLevel', title: '层级', align: 'center'},
                            {field: 'Flag', title: '标识', align: 'center',
                                formatter: function (value,row) {
                                    let html = "";
                                    if (value == 0) {
                                        html = "集团"
                                    } else if (value == 1) {
                                        html = "三大中心"
                                    } else if (value == 2) {
                                        html = "营销中心"
                                    } else if (value == 3) {
                                        html = "生产中心"
                                    } else if (value == 4) {
                                        html = "保障中心"
                                    }
                                    return html;
                                }
                            },
                            {field: 'Active', title: '是否启用', align: 'center',
                                formatter: function (value,row) {
                                    return value == 1 ? '<label class="text-success">启用</label>' : '<label class="text-danger">不启用</label>';
                                }
                            },
                            {
                                field: 'do', title: '操作', align: 'center',
                                formatter: function (value, row, index) {
                                    let content = row.Name ? encodeURI(row.Name.replace(/[\r\n]/g, "")) : '-';
                                    return '<a href="javascript:void(0)" onclick="DOCTOR.Select.toAdd(' + row.Id + ',\'' + content + '\',\'' + fieldId + '\')" class="text-do-add"><i class="fa fa-plus glyphicon_size"></i></a>';
                                }
                            }
                        ],
                        onPageChange: function (number, size) {
                            that.showOrgData(number, size, fieldId);
                        },
                        onRefreshTable: function () {   //表格右侧刷新按钮
                            that.showOrgData(obj.pageNumber, obj.pageSize, fieldId);
                        }
                    });
                    that.showLoading(false);
                }
            });
        },
        showOrgEvent: function (fieldId) {
            var that = this;
            // 对用户添加Enter键支持
            var $stb = $("#search-toolbar-common");
            $stb.on("click", "#tool_btn_search", function () {
                that.showOrgData(1, 5, fieldId);
            }).on("keydown", "input", function (e) {
                if (e.keyCode == 13) {
                    that.showOrgData(1, 5, fieldId);
                }
            }).on('click', "#tool_btn_remove", function () {
                $("#" + fieldId).val('');
                $("#" + fieldId).removeAttr('data-id');
                $("#tool_modal").modal('hide');
            });
            that.initEvent();
        },

        /**
         * 法人公司
         *
         * @param obj
         */
        showCompany: function (obj) {
            var that = this;
            var search = '';
            search += '<div class="form-group">';
            search += '<input id="tool_s_id" type="text" class="form-control" placeholder="公司ID">';
            search += '<input id="tool_s_number" type="text" class="form-control" placeholder="公司编码">';
            search += '<input id="tool_s_name" type="text" class="form-control" placeholder="公司名称">';
            search += '</div>';
            var $userModal = $(that.initModal('公司列表', search));
            $(document.body).append($userModal);
            $userModal.modal('show');
            that.showCompanyData(1, 10, obj.id);
            that.showCompanyEvent(obj.id);
        },
        showCompanyData: function (pageNumber, pageSize, fieldId) {
            var that = this;
            that.showLoading(true);

            let search_id = $("#tool_s_id").val();
            let search_number = $("#tool_s_number").val();
            let search_name = $("#tool_s_name").val();

            if (typeof(search_name) == "undefined") {
                search_name = '';
            }
            SYS.Core.ajax({
                url: "base/company/list",
                common: {
                    page: pageNumber ? pageNumber : 1,
                    size: pageSize ? pageSize : 5,
                    order: "create_time:-1"
                },
                data: {
                    Id: search_id,
                    Code: search_number,
                    Name: search_name
                },
                success: function (data) {
                    var obj = {
                        'pageNumber': data.data.extra.current_page,
                        'pageSize': data.data.extra.page_size,
                        'totalRows': data.data.extra.all_count,
                        'data': data.data.list
                    };
                    $("#tool_table").bootstrapTable('destroy');    //销毁table
                    $('#tool_table').bootstrapTable({
                        striped: true,
                        singleSelect: true,
                        pagination: true,
                        paginationDetail: false,
                        pageNumber: obj.pageNumber,
                        pageSize: obj.pageSize,
                        totalRows: obj.totalRows,
                        pageList: [10, 50, 100, 200],
                        sidePagination: 'server',
                        clickToSelect: true,
                        idField: '_id',
                        data: obj.data,
                        columns: [
                            {field: 'Id', title: '公司ID', align: 'center'},
                            {field: 'Code', title: '公司编码', align: 'center'},
                            {field: 'Name', title: '公司名称', align: 'center'},
                            {field: 'ParentId', title: '上级公司', align: 'center',
                                formatter:function (value, row){
                                    let html = '';
                                    if (value) {
                                        let parentCompanyInfo = row.ParentCompanyInfo;
                                        if(parentCompanyInfo) {
                                            html = parentCompanyInfo.Name + "<br/>" + parentCompanyInfo.Code + "<br/>(" + value + ")";
                                        } else {
                                            html = value
                                        }
                                    }
                                    return html;
                                }
                            },
                            {
                                field: 'IsLeaf', title: '是否叶子节点', align: 'center',
                                formatter: function (value, row, index) {
                                    return value == 0 ? '<label class="text-danger">否</label>' : '<label class="text-success">是</label>';
                                }
                            },
                            {
                                field: 'IsGroup', title: '是否为集团公司', align: 'center',
                                formatter: function (value, row, index) {
                                    return value == 0 ? '<label class="text-danger">否</label>' : '<label class="text-success">是</label>';
                                }
                            },
                            // {field: 'BelongTo', title: '管理口径归属', align: 'center'},
                            {
                                field: 'Actived', title: '启用的', align: 'center',
                                formatter: function (value, row, index) {
                                    return value == 0 ? '不启用' : '启用';
                                }
                            },
                            {
                                field: 'do', title: '操作', align: 'center',
                                formatter: function (value, row, index) {
                                    let content = row.Name ? row.Name.replace(/[\r\n]/g, "") : '-';
                                    let code = row.Code ? row.Code : '-';
                                    return '<a href="javascript:void(0)" onclick="DOCTOR.Select.toAdd2(\'' + row.Id + '\',\'' + content + '\',\''+ code + '\',\'' + fieldId + '\')" class="text-do-add"><i class="fa fa-plus glyphicon_size"></i></a>';
                                }
                            }
                        ],
                        onPageChange: function (number, size) {
                            that.showCompanyData(number, size, fieldId);
                        },
                        onRefreshTable: function () {   //表格右侧刷新按钮
                            that.showCompanyData(obj.pageNumber, obj.pageSize, fieldId);
                        }
                    });
                    that.showLoading(false);
                }
            });
        },
        showCompanyEvent: function (fieldId) {
            var that = this;
            // 对用户添加Enter键支持
            var $stb = $("#search-toolbar-common");
            $stb.on("click", "#tool_btn_search", function () {
                that.showCompanyData(1, 5, fieldId);
            }).on("keydown", "input", function (e) {
                if (e.keyCode == 13) {
                    that.showCompanyData(1, 5, fieldId);
                }
            }).on('click', "#tool_btn_remove", function () {
                $("#" + fieldId).val('');
                $("#" + fieldId).removeAttr('data-id');
                $("#tool_modal").modal('hide');
            });
            that.initEvent();
        },
        /**
         * 成本中心
         *
         * @param obj
         */
        showCostCenter: function (obj) {
            var that = this;
            var search = '';
            search += '<div class="form-group">';
            search += '<input id="tool_s_id" type="text" class="form-control" placeholder="成本中心ID">';
            search += '<input id="tool_s_number" type="text" class="form-control" placeholder="成本中心编码">';
            search += '<input id="tool_s_name" type="text" class="form-control" placeholder="成本中心名称">';
            search += '</div>';
            var $userModal = $(that.initModal('成本列表', search));
            $(document.body).append($userModal);
            $userModal.modal('show');
            that.showCostCenterData(1, 10, obj.id);
            that.showCostCenterEvent(obj.id);
        },
        showCostCenterData: function (pageNumber, pageSize, fieldId) {
            var that = this;
            that.showLoading(true);

            let search_id = $("#tool_s_id").val();
            let search_number = $("#tool_s_number").val();
            let search_name = $("#tool_s_name").val();

            if (typeof(search_name) == "undefined") {
                search_name = '';
            }
            SYS.Core.ajax({
                url: "base/costCenter/list",
                common: {
                    page: pageNumber ? pageNumber : 1,
                    size: pageSize ? pageSize : 5,
                    order: "create_time:-1"
                },
                data: {
                    Id: search_id,
                    Code: search_number,
                    Name: search_name,
                    Type: -1
                },
                success: function (data) {
                    var obj = {
                        'pageNumber': data.data.extra.current_page,
                        'pageSize': data.data.extra.page_size,
                        'totalRows': data.data.extra.all_count,
                        'data': data.data.list
                    };
                    $("#tool_table").bootstrapTable('destroy');    //销毁table
                    $('#tool_table').bootstrapTable({
                        striped: true,
                        singleSelect: true,
                        pagination: true,
                        paginationDetail: false,
                        pageNumber: obj.pageNumber,
                        pageSize: obj.pageSize,
                        totalRows: obj.totalRows,
                        pageList: [10, 50, 100, 200],
                        sidePagination: 'server',
                        clickToSelect: true,
                        idField: '_id',
                        data: obj.data,
                        columns: [
                            {field: 'Id', title: '成功中心ID', align: 'center'},
                            {field: 'Code', title: '成本中心编码', align: 'center'},
                            {field: 'Name', title: '成本中心名称', align: 'center'},
                            {
                                field: 'ParentId', title: '上级成本中心', align: 'center',
                                formatter:function (value, row){
                                    let html = '';
                                    if (value) {
                                        let parentInfo = row.ParentInfo;
                                        if(parentInfo) {
                                            html = parentInfo.Name + "<br/>" + parentInfo.Code + "<br/>(" + value + ")";
                                        } else {
                                            html = value
                                        }
                                    }
                                    return html;
                                }
                            },
                            {field: 'IsLeaf', title: '是否叶子节点', align: 'center',
                                formatter: function (value, row, index) {
                                    return value == 0 ? '<label class="text-danger">否</label>' : '<label class="text-success">是</label>';
                                }
                            },
                            {field: 'Type', title: '类型', align: 'center',
                                formatter: function (value, row, index) {
                                    let html = '';
                                    switch (value){
                                        case 0:
                                            html = '直接生产部门 ';
                                            break;
                                        case 1:
                                            html = '辅助生产部门 ';
                                            break;
                                        case 2:
                                            html = '管理部门 ';
                                            break;
                                        case 3:
                                            html = '销售部门';
                                            break;
                                    }
                                    return html;
                                }
                            },
                            {
                                field: 'do', title: '操作', align: 'center',
                                formatter: function (value, row, index) {
                                    let content = row.Name ? encodeURI(row.Name.replace(/[\r\n]/g, "")) : '-';
                                    let code = row.Code ? row.Code : '-';
                                    return '<a href="javascript:void(0)" onclick="DOCTOR.Select.toAdd2(\'' + row.Id + '\',\'' + content + '\',\'' + code + '\',\'' + fieldId + '\')" class="text-do-add"><i class="fa fa-plus glyphicon_size"></i></a>';
                                }
                            }
                        ],
                        onPageChange: function (number, size) {
                            that.showCostCenterData(number, size, fieldId);
                        },
                        onRefreshTable: function () {   //表格右侧刷新按钮
                            that.showCostCenterData(obj.pageNumber, obj.pageSize, fieldId);
                        }
                    });
                    that.showLoading(false);
                }
            });
        },
        showCostCenterEvent: function (fieldId) {
            var that = this;
            // 对用户添加Enter键支持
            var $stb = $("#search-toolbar-common");
            $stb.on("click", "#tool_btn_search", function () {
                that.showCostCenterData(1, 5, fieldId);
            }).on("keydown", "input", function (e) {
                if (e.keyCode == 13) {
                    that.showCostCenterData(1, 5, fieldId);
                }
            }).on('click', "#tool_btn_remove", function () {
                $("#" + fieldId).val('');
                $("#" + fieldId).removeAttr('data-id');
                $("#tool_modal").modal('hide');
            });
            that.initEvent();
        },
        /**
         * 科目
         * @param obj
         */
        showAccountView: function (obj) {
            var that = this;
            var search = '';
            search += '<div class="form-group">';
            search += '<input id="tool_s_id" type="number" class="form-control" placeholder="科目ID">';
            search += '<input id="tool_s_number" type="text" class="form-control" placeholder="科目编码">';
            search += '<input id="tool_s_name" type="text" class="form-control" placeholder="科目名称">';
            search += '</div>';
            var $userModal = $(that.initModal('科目列表', search));
            $(document.body).append($userModal);
            $userModal.modal('show');
            that.showAccountViewData(1, 10, obj.id);
            that.showAccountViewEvent(obj.id);
        },
        showAccountViewData: function (pageNumber, pageSize, fieldId) {
            var that = this;
            that.showLoading(true);

            let search_id = $("#tool_s_id").val();
            let search_number = $("#tool_s_number").val();
            let search_name = $("#tool_s_name").val();

            if (typeof(search_name) == "undefined") {
                search_name = '';
            }
            SYS.Core.ajax({
                url: "base/accountView/list",
                common: {
                    page: pageNumber ? pageNumber : 1,
                    size: pageSize ? pageSize : 5,
                    order: "create_time:-1"
                },
                data: {
                    Code : search_number,
                    Name: search_name
                },
                success: function (data) {
                    var obj = {
                        'pageNumber': data.data.extra.current_page,
                        'pageSize': data.data.extra.page_size,
                        'totalRows': data.data.extra.all_count,
                        'data': data.data.list
                    };
                    $("#tool_table").bootstrapTable('destroy');    //销毁table
                    $('#tool_table').bootstrapTable({
                        striped: true,
                        singleSelect: true,
                        pagination: true,
                        paginationDetail: false,
                        pageNumber: obj.pageNumber,
                        pageSize: obj.pageSize,
                        totalRows: obj.totalRows,
                        pageList: [10, 50, 100, 200],
                        sidePagination: 'server',
                        clickToSelect: true,
                        idField: '_id',
                        data: obj.data,
                        columns: [
                            {field: 'checked', checkbox: true} ,
                            {field: 'Code', title: '科目编码', align: 'center'},
                            {field: 'Name', title: '科目名称', align: 'center'},
                            {field: 'ParentCode', title: '上级科目', align: 'center'},
                            {field: 'IsLeaf', title: '是否叶子节点', align: 'center'},
                            {
                                field: 'do', title: '操作', align: 'center',
                                formatter: function (value, row, index) {
                                    let content = row.Name ? encodeURI(row.Name.replace(/[\r\n]/g, "")) : '-';
                                    return '<a href="javascript:void(0)" onclick="DOCTOR.Select.toAdd(\'' + row.Code + '\',\'' + content + '\',\'' + fieldId + '\')" class="text-do-add"><i class="fa fa-plus glyphicon_size"></i></a>';
                                }
                            }
                        ],
                        onPageChange: function (number, size) {
                            that.showAccountViewData(number, size, fieldId);
                        },
                        onRefreshTable: function () {   //表格右侧刷新按钮
                            that.showAccountViewData(obj.pageNumber, obj.pageSize, fieldId);
                        }
                    });
                    that.showLoading(false);
                }
            });
        },
        showAccountViewEvent: function (fieldId) {
            var that = this;
            // 对用户添加Enter键支持
            var $stb = $("#search-toolbar-common");
            $stb.on("click", "#tool_btn_search", function () {
                that.showAccountViewData(1, 5, fieldId);
            }).on("keydown", "input", function (e) {
                if (e.keyCode == 13) {
                    that.showAccountViewData(1, 5, fieldId);
                }
            }).on('click', "#tool_btn_remove", function () {
                $("#" + fieldId).val('');
                $("#" + fieldId).removeAttr('data-id');
                $("#tool_modal").modal('hide');
            });
            that.initEvent();
        },
        /**
         * 利润模板
         * @param obj
         */
        showProfitTableTemplate: function (obj) {
            var that = this;
            var search = '';
            search += '<div class="form-group">';
            search += '<input id="tool_s_id" type="number" class="form-control" placeholder="利润模版ID">';
            search += '<input id="tool_s_name" type="text" class="form-control" placeholder="利润模版名称">';
            search += '</div>';
            var $userModal = $(that.initModal('利润模板列表', search));
            $(document.body).append($userModal);
            $userModal.modal('show');
            that.showProfitTableTemplateData(1, 10, obj.id);
            that.showProfitTableTemplateEvent(obj.id);
        },
        showProfitTableTemplateData: function (pageNumber, pageSize, fieldId) {
            var that = this;
            that.showLoading(true);

            let search_id = $("#tool_s_id").val();
            let search_name = $("#tool_s_name").val();
            if (typeof(search_name) == "undefined") {
                search_name = '';
            }
            SYS.Core.ajax({
                url: "base/profitTableTemplate/list",
                common: {
                    page: pageNumber ? pageNumber : 1,
                    size: pageSize ? pageSize : 5,
                    order: "create_time:-1"
                },
                data: {
                    Id: search_id || 0,
                    Name: search_name,
                    Active: 1
                },
                success: function (data) {
                    var obj = {
                        'pageNumber': data.data.extra.current_page,
                        'pageSize': data.data.extra.page_size,
                        'totalRows': data.data.extra.all_count,
                        'data': data.data.list
                    };
                    $("#tool_table").bootstrapTable('destroy');    //销毁table
                    $('#tool_table').bootstrapTable({
                        striped: true,
                        singleSelect: true,
                        pagination: true,
                        paginationDetail: false,
                        pageNumber: obj.pageNumber,
                        pageSize: obj.pageSize,
                        totalRows: obj.totalRows,
                        pageList: [10, 50, 100, 200],
                        sidePagination: 'server',
                        clickToSelect: true,
                        idField: '_id',
                        data: obj.data,
                        columns: [
                            {field: 'checked', checkbox: true} ,
                            {field: 'Id', title: '编号', align: 'center'},
                            {field: 'Name', title: '利润模版名称', align: 'center'},
                            {field: 'Active', title: '是否启用', align: 'center'},
                            {
                                field: 'do', title: '操作', align: 'center',
                                formatter: function (value, row, index) {
                                    let content = row.Name ? encodeURI(row.Name.replace(/[\r\n]/g, "")) : '-';
                                    return '<a href="javascript:void(0)" onclick="DOCTOR.Select.toAdd(' + row.Id + ',\'' + content + '\',\'' + fieldId + '\')" class="text-do-add"><i class="fa fa-plus glyphicon_size"></i></a>';
                                }
                            }
                        ],
                        onPageChange: function (number, size) {
                            that.showProfitTableTemplateData(number, size, fieldId);
                        },
                        onRefreshTable: function () {   //表格右侧刷新按钮
                            that.showProfitTableTemplateData(obj.pageNumber, obj.pageSize, fieldId);
                        }
                    });
                    that.showLoading(false);
                }
            });
        },
        showProfitTableTemplateEvent: function (fieldId) {
            var that = this;
            // 对用户添加Enter键支持
            var $stb = $("#search-toolbar-common");
            $stb.on("click", "#tool_btn_search", function () {
                that.showProfitTableTemplateData(1, 5, fieldId);
            }).on("keydown", "input", function (e) {
                if (e.keyCode == 13) {
                    that.showProfitTableTemplateData(1, 5, fieldId);
                }
            }).on('click', "#tool_btn_remove", function () {
                $("#" + fieldId).val('');
                $("#" + fieldId).removeAttr('data-id');
                $("#tool_modal").modal('hide');
            });
            that.initEvent();
        },
        /**
         * 报表项目
         * @param obj
         */
        showProfitReportItem: function (obj) {
            var that = this;
            var search = '';
            search += '<div class="form-group">';
            search += '<input id="tool_s_id" type="number" class="form-control" placeholder="报表项目ID">';
            search += '<input id="tool_s_name" type="text" class="form-control" placeholder="报表项目名称">';
            search += '</div>';
            var $userModal = $(that.initModal('报表项目列表', search));
            $(document.body).append($userModal);
            $userModal.modal('show');
            that.showProfitReportItemData(1, 10, obj.id);
            that.showProfitReportItemEvent(obj.id);
        },
        showProfitReportItemData: function (pageNumber, pageSize, fieldId) {
            var that = this;
            that.showLoading(true);

            let search_id = $("#tool_s_id").val();
            let search_name = $("#tool_s_name").val();
            if (typeof(search_name) == "undefined") {
                search_name = '';
            }
            SYS.Core.ajax({
                url: "base/profitReportItem/list",
                common: {
                    page: pageNumber ? pageNumber : 1,
                    size: pageSize ? pageSize : 5,
                    order: "create_time:-1"
                },
                data: {
                    Id: search_id || 0,
                    Name: search_name
                },
                success: function (data) {
                    var obj = {
                        'pageNumber': data.data.extra.current_page,
                        'pageSize': data.data.extra.page_size,
                        'totalRows': data.data.extra.all_count,
                        'data': data.data.list
                    };
                    $("#tool_table").bootstrapTable('destroy');    //销毁table
                    $('#tool_table').bootstrapTable({
                        striped: true,
                        singleSelect: true,
                        pagination: true,
                        paginationDetail: false,
                        pageNumber: obj.pageNumber,
                        pageSize: obj.pageSize,
                        totalRows: obj.totalRows,
                        pageList: [10, 50, 100, 200],
                        sidePagination: 'server',
                        clickToSelect: true,
                        idField: '_id',
                        data: obj.data,
                        columns: [
                            {field: 'checked', checkbox: true} ,
                            {field: 'Id', title: '编号', align: 'center'},
                            {field: 'Name', title: '报表项目名称', align: 'center'},
                            {field: 'Type', title: '类型', align: 'center',
                                formatter: function (value,row) {
                                    let html = ''
                                    if(value == 10) {
                                        html = "科目汇总"
                                    } else if(value == 20) {
                                        html = "公式"
                                    }
                                    return html;
                                }
                            },
                            {
                                field: 'do', title: '操作', align: 'center',
                                formatter: function (value, row, index) {
                                    let content = row.Name ? encodeURI(row.Name.replace(/[\r\n]/g, "")) : '-';
                                    return '<a href="javascript:void(0)" onclick="DOCTOR.Select.toAdd(' + row.Id + ',\'' + content + '\',\'' + fieldId + '\')" class="text-do-add"><i class="fa fa-plus glyphicon_size"></i></a>';
                                }
                            }
                        ],
                        onPageChange: function (number, size) {
                            that.showProfitReportItemData(number, size, fieldId);
                        },
                        onRefreshTable: function () {   //表格右侧刷新按钮
                            that.showProfitReportItemData(obj.pageNumber, obj.pageSize, fieldId);
                        }
                    });
                    that.showLoading(false);
                }
            });
        },
        showProfitReportItemEvent: function (fieldId) {
            var that = this;
            // 对用户添加Enter键支持
            var $stb = $("#search-toolbar-common");
            $stb.on("click", "#tool_btn_search", function () {
                that.showProfitReportItemData(1, 5, fieldId);
            }).on("keydown", "input", function (e) {
                if (e.keyCode == 13) {
                    that.showProfitReportItemData(1, 5, fieldId);
                }
            }).on('click', "#tool_btn_remove", function () {
                $("#" + fieldId).val('');
                $("#" + fieldId).removeAttr('data-id');
                $("#tool_modal").modal('hide');
            });
            that.initEvent();
        },

        /**
         * 产品
         * @param obj
         */
        showMaterial: function (obj) {
            var that = this;
            var search = '';
            search += '<div class="form-group">';
            search += '<input id="tool_s_id" type="text" class="form-control" placeholder="产品ID">';
            search += '<input id="tool_s_code" type="text" class="form-control" placeholder="产品编码">';
            search += '<input id="tool_s_name" type="text" class="form-control" placeholder="产品名称">';
            search += '</div>';
            var $userModal = $(that.initModal('产品列表', search));
            $(document.body).append($userModal);
            $userModal.modal('show');
            that.showMaterialData(1, 10, obj.id);
            that.showMaterialEvent(obj.id);
        },
        showMaterialData: function (pageNumber, pageSize, fieldId) {
            var that = this;
            that.showLoading(true);

            let search_id = $("#tool_s_id").val();
            let search_code = $("#tool_s_code").val();
            let search_name = $("#tool_s_name").val();
            if (typeof(search_id) == "undefined") {
                search_id = '';
            }
            if (typeof(search_code) == "undefined") {
                search_code = '';
            }
            if (typeof(search_name) == "undefined") {
                search_name = '';
            }
            SYS.Core.ajax({
                url: "base/material/list",
                common: {
                    page: pageNumber ? pageNumber : 1,
                    size: pageSize ? pageSize : 5,
                    order: "create_time:-1"
                },
                data: {
                    Id: search_id,
                    Code: search_code,
                    Name: search_name
                },
                success: function (data) {
                    var obj = {
                        'pageNumber': data.data.extra.current_page,
                        'pageSize': data.data.extra.page_size,
                        'totalRows': data.data.extra.all_count,
                        'data': data.data.list
                    };
                    $("#tool_table").bootstrapTable('destroy');    //销毁table
                    $('#tool_table').bootstrapTable({
                        striped: true,
                        singleSelect: true,
                        pagination: true,
                        paginationDetail: false,
                        pageNumber: obj.pageNumber,
                        pageSize: obj.pageSize,
                        totalRows: obj.totalRows,
                        pageList: [10, 50, 100, 200],
                        sidePagination: 'server',
                        clickToSelect: true,
                        idField: '_id',
                        data: obj.data,
                        columns: [
                            {field: 'Id', title: '产品ID', align: 'center'},
                            {field: 'Code', title: '产品编码', align: 'center'},
                            {field: 'Name', title: '产品名称', align: 'center'},
                            {field: 'GroupName', title: '产分类别', align: 'center'},
                            {field: 'QtyPerPack', title: '每箱瓶数', align: 'center'},
                            {field: 'QtyPerStdPack', title: '标准箱瓶数', align: 'center'},
                            {field: 'BaseUnit', title: '计量单位', align: 'center'},
                            {
                                field: 'do', title: '操作', align: 'center',
                                formatter: function (value, row, index) {
                                    let content = row.Name ? encodeURI(row.Name.replace(/[\r\n]/g, "")) : '-';
                                    let code = row.Code || '';
                                    let perPack = row.QtyPerPack || 0;
                                    let perStdPack = row.QtyPerStdPack || 0;
                                    let groupName = row.GroupName;
                                    return '<a href="javascript:void(0)" onclick="DOCTOR.Select.toAddMaterial(\'' + row.Id + '\',\'' + content + '\',\'' + fieldId + '\',\''+ code + '\','+ perPack + ',' + perStdPack +',\''+groupName+'\')" class="text-do-add"><i class="fa fa-plus glyphicon_size"></i></a>';
                                }
                            }
                        ],
                        onPageChange: function (number, size) {
                            that.showMaterialData(number, size, fieldId);
                        },
                        onRefreshTable: function () {   //表格右侧刷新按钮
                            that.showMaterialData(obj.pageNumber, obj.pageSize, fieldId);
                        }
                    });
                    that.showLoading(false);
                }
            });
        },
        showMaterialEvent: function (fieldId) {
            var that = this;
            // 对用户添加Enter键支持
            var $stb = $("#search-toolbar-common");
            $stb.on("click", "#tool_btn_search", function () {
                that.showMaterialData(1, 5, fieldId);
            }).on("keydown", "input", function (e) {
                if (e.keyCode == 13) {
                    that.showMaterialData(1, 5, fieldId);
                }
            }).on('click', "#tool_btn_remove", function () {
                $("#" + fieldId).val('');
                $("#" + fieldId).removeAttr('data-id');
                $("#tool_modal").modal('hide');
            });
            that.initEvent();
        },

        /**
         * 会计期间
         * @param obj
         */
        showPeriod: function (obj, PeriodQuarter, PeriodMonth) {
            var that = this;
            var search = '';
            search += '<div class="form-group">';
            search += '<input id="tool_s_id" type="text" class="form-control" placeholder="产品ID">';
            search += '<input id="tool_s_code" type="text" class="form-control" placeholder="产品编码">';
            search += '</div>';
            var $userModal = $(that.initModal('会计期间列表', search));
            $(document.body).append($userModal);
            $userModal.modal('show');
            that.showPeriodData(1, 10, obj.id, PeriodQuarter, PeriodMonth);
            that.showPeriodEvent(obj.id, PeriodQuarter, PeriodMonth);
        },
        showPeriodData: function (pageNumber, pageSize, fieldId, PeriodQuarter, PeriodMonth) {
            var that = this;
            that.showLoading(true);

            let search_id = $("#tool_s_id").val();
            let search_code = $("#tool_s_code").val();
            if (typeof(search_code) == "undefined") {
                search_code = '';
            }

            SYS.Core.ajax({
                url: "base/period/list",
                common: {
                    page: pageNumber ? pageNumber : 1,
                    size: pageSize ? pageSize : 5,
                    order: "create_time:-1"
                },
                data: {
                    Id: search_id,
                    Code: search_code
                },
                success: function (data) {
                    var obj = {
                        'pageNumber': data.data.extra.current_page,
                        'pageSize': data.data.extra.page_size,
                        'totalRows': data.data.extra.all_count,
                        'data': data.data.list
                    };
                    $("#tool_table").bootstrapTable('destroy');    //销毁table
                    $('#tool_table').bootstrapTable({
                        striped: true,
                        singleSelect: true,
                        pagination: true,
                        paginationDetail: false,
                        pageNumber: obj.pageNumber,
                        pageSize: obj.pageSize,
                        totalRows: obj.totalRows,
                        pageList: [10, 50, 100, 200],
                        sidePagination: 'server',
                        clickToSelect: true,
                        idField: '_id',
                        data: obj.data,
                        columns: [
                            {field: 'Id', title: '会计期间ID', align: 'center'},
                            {field: 'Code', title: '会计期间编码', align: 'center'},
                            {field: 'PeriodYear', title: '会计年度', align: 'center'},
                            {field: 'PeriodQuarter', title: '会计季度', align: 'center'},
                            {field: 'PeriodMonth', title: '会计月度', align: 'center'},
                            {field: 'BeginDate', title: '开始日期', align: 'center'},
                            {field: 'EndDate', title: '结束日期', align: 'center'},
                            {
                                field: 'do', title: '操作', align: 'center',
                                formatter: function (value, row, index) {
                                    let content = row.Code ? encodeURI(row.Code.replace(/[\r\n]/g, "")) : '-';
                                    let periodQuarter = row.PeriodQuarter || 0;
                                    let periodMonth = row.PeriodMonth || 0;
                                    let periodYear = row.PeriodYear || 0;
                                    let code = row.Code || 0;
                                    return '<a href="javascript:void(0)" onclick="DOCTOR.Select.toAddPeriod(\'' + row.Id + '\',\'' + content + '\',\'' + fieldId + '\','+ periodQuarter +','+ periodMonth+','+ periodYear+',\''+ code +'\')" class="text-do-add"><i class="fa fa-plus glyphicon_size"></i></a>';
                                }
                            }
                        ],
                        onPageChange: function (number, size) {
                            that.showPeriodData(number, size, fieldId);
                        },
                        onRefreshTable: function () {   //表格右侧刷新按钮
                            that.showPeriodData(obj.pageNumber, obj.pageSize, fieldId);
                        }
                    });
                    that.showLoading(false);
                }
            });
        },
        showPeriodEvent: function (fieldId, PeriodQuarter, PeriodMonth) {
            var that = this;
            // 对用户添加Enter键支持
            var $stb = $("#search-toolbar-common");
            $stb.on("click", "#tool_btn_search", function () {
                that.showPeriodData(1, 5, fieldId);
            }).on("keydown", "input", function (e) {
                if (e.keyCode == 13) {
                    that.showPeriodData(1, 5, fieldId);
                }
            }).on('click', "#tool_btn_remove", function () {
                $("#" + fieldId).val('');
                $("#" + fieldId).removeAttr('data-id');
                $("#tool_modal").modal('hide');
            });
            that.initEvent();
        },

        toAdd: function (id, content, field) {
            $("#" + field).val(decodeURI(content));
            $("#" + field).attr("data-id", id);
            $("#tool_modal").modal('hide');
        },
        toAdd2: function (id, content, code, field, PeriodQuarter, PeriodMonth) {
            $("#" + field).val(decodeURI(content));
            $("#" + field).attr("data-id", id);
            $("#" + field).attr("data-name", decodeURI(content));
            $("#" + field).attr("data-code", code);
            $("#tool_modal").modal('hide');
        },
        toAddMaterial: function (id, content, field, code, packQuantity, stdPackQuantity, groupName) {
            $("#" + field).val(decodeURI(content));
            $("#" + field).attr("data-id", id);
            $("#" + field).attr("data-code", code);

            $("#MaterialCode").val(code);
            $("#MaterialName").val(decodeURI(content));
            $("#PackQuantity").val(packQuantity);
            $("#StdPackQuantity").val(stdPackQuantity);
            if(groupName){
                $("#GroupName").val(groupName);
            }
            $("#tool_modal").modal('hide');
        },
        toAddPeriod: function (id, content, field, periodQuarter, periodMonth, periodYear, code) {
            $("#" + field).val(decodeURI(content));
            $("#" + field).attr("data-id", id);
            $("#" + field).attr("data-code", code);

            $("#PeriodCode").val(code);
            $("#PeriodQuarter").val(periodQuarter);
            $("#PeriodMonth").val(periodMonth);
            if(periodYear){
                $("#PeriodYear").val(periodYear);
            }
            $("#tool_modal").modal('hide');
        },
        initModal: function (title, search) {
            var modal = '';
            modal += '<div id="tool_modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">';
            modal += '  <div class="modal-dialog modal-lg">';
            modal += '      <div class="modal-content">';
            modal += '          <div class="modal-header">';
            modal += '              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>';
            modal += '              <h4 class="modal-title">' + title + '</h4>';
            modal += '          </div>';
            modal += '          <div class="modal-body">';
            modal += '              <div class="spiner-example" id="tool_loading">';
            modal += '                  <div class="sk-spinner sk-spinner-wave">';
            modal += '                      <div class="sk-rect1"></div>';
            modal += '                      <div class="sk-rect2"></div>';
            modal += '                      <div class="sk-rect3"></div>';
            modal += '                      <div class="sk-rect4"></div>';
            modal += '                      <div class="sk-rect5"></div>';
            modal += '                  </div>';
            modal += '              </div>';
            modal += '              <div class="row" id="tool_detail" style="display: none;">';
            modal += '                  <div id="search-toolbar-common" class="search-toolbar">';
            modal += '                      <div class="form-inline" role="form">';
            modal += search;
            modal += '                          <div class="form-group">';
            modal += '                              <button id="tool_btn_search" type="button" class="btn btn-search" ><i class="fa fa-search"> </i> 搜索</button>';
            // modal += '                              <button id="tool_btn_remove" type="button" class="btn btn-white" ><i class="fa fa-remove"> </i> 取消</button>';
            modal += '                          </div>';
            modal += '                      </div>';
            modal += '                  </div>';
            modal += '                  <div style="margin-top: 10px;"></div>';
            modal += '                  <table id="tool_table" data-click-to-select="true"></table>';
            modal += '              </div>';
            modal += '          </div>';
            modal += '      </div>';
            modal += '  </div>';
            modal += '</div>';
            return modal;
        },
        initEvent: function () {
            $('#tool_modal').on('hide.bs.modal', function () {
                $("#tool_modal").remove();
            });
        },
        showLoading: function (isShow) {
            if (isShow) {
                $("#tool_loading").show();
                $("#tool_detail").hide();
            } else {
                $("#tool_loading").hide();
                $("#tool_detail").show();
            }

        }
    }
});